local df_fengkuang = fk.CreateSkill {
  name = "df_fengkuang",
  tags = { Skill.Compulsory, },
}


df_fengkuang:addEffect(fk.HpChanged, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    if not player:hasSkill(df_fengkuang.name) then return end
    if player == target and player.id < 0 then
      if player:getMark("df_fengkuang") == 0 and player.hp <= player.maxHp / 2 then
        return true
      end
      if player:getMark("df_fengkuang") ~= 0 and player.hp > player.maxHp / 2 then
        return true
      end
    end
    return false
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getMark("df_fengkuang") ~= 0 and player.hp > player.maxHp / 2 then
      room:setPlayerMark(player,"df_fengkuang",0)
    end
    if player.hp <= player.maxHp / 2 then
      room:setPlayerMark(player,"df_fengkuang",1)
    end
  end,
})
df_fengkuang:addEffect(fk.DamageCaused, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    if not player:hasSkill(df_fengkuang.name) then return end
    return player == target and data.from == player and data.card and player.hp <= player.maxHp / 2
  end,
  on_use = function(self, event, target, player, data)
    data.damage = data.damage * 2
  end,
})


return df_fengkuang